home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 2 / MacMania 2.toast / Demo's / Tools&Utilities / Programming / FBSpriteWorld 1.05b / Project 1.01b / SWStandardProcs.txt < prev    next >
Encoding:
Text File  |  1994-07-07  |  3.0 KB  |  77 lines  |  [TEXT/ZBAS]

  1. 'SWStandardProcs.txt by Robert Hommel
  2. '© Copyright 1994
  3. 'All rights granted for any use whatsoever
  4.  
  5. 'This file contains the standard movement and time task procedures for 
  6. 'FBSpriteWorld.  Since there is no easy way to place ENTERPROC/EXITPROC
  7. 'procedures in an Include file, you should copy and paste these 
  8. 'procedures into your MAIN program file.  
  9.  
  10. 'NOTE:  You should always paste the "SWTimeTask" procedure in your
  11. 'MAIN file.  You should paste one or both standard movement procs
  12. 'in your MAIN file if you have Sprites that use them to define their
  13. 'movement characteristics.
  14.  
  15. 'Disclaimer:  I've tested these routines quite thoroughly on my Mac
  16. 'LC running System 7.01 and FB 1.02c.  I make no promises or warranties 
  17. 'of any kind.
  18. '*********************************************************************
  19.  
  20. '------------------------ SPRITEWORLD PROCS --------------------------
  21.  
  22. "SWBounceMoveProc"
  23. ENTERPROC(SWPtr&,spritePtr&,curRectPtr&)
  24.   'standard bounce movement proc.  Keeps sprite inside sprite boundsRect
  25.   
  26.   LONG IF curRectPtr&.left%+spritePtr&.xDelta%<=spritePtr&.sBoundsRect.left%
  27.     spritePtr&.xDelta%=spritePtr&.xDelta%*-1
  28.   XELSE
  29.     LONG IF curRectPtr&.right%+spritePtr&.xDelta%>=spritePtr&.sBoundsRect.right%
  30.       spritePtr&.xDelta%=spritePtr&.xDelta%*-1
  31.     END IF
  32.   END IF
  33.   LONG IF curRectPtr&.top%+spritePtr&.yDelta%<=spritePtr&.sBoundsRect.top%
  34.     spritePtr&.yDelta%=spritePtr&.yDelta%*-1
  35.   XELSE
  36.     LONG IF curRectPtr&.bottom%+spritePtr&.yDelta%>=spritePtr&.sBoundsRect.bottom%
  37.       spritePtr&.yDelta%=spritePtr&.yDelta%*-1
  38.     END IF
  39.   END IF
  40. EXITPROC
  41. RETURN
  42.  
  43. "SWWrapMoveProc"
  44. ENTERPROC(SWPtr&,spritePtr&,curRectPtr&)
  45.   'standard wrap movement proc.  Sprite wraps within sprite boundsRect
  46.   
  47.   LONG IF curRectPtr&.right%+spritePtr&.xDelta%<=spritePtr&.sBoundsRect+_left%
  48.     curRectPtr&.right%=spritePtr&.sBoundsRect.right%+(curRectPtr&.right%-curRectPtr&.left%)
  49.     curRectPtr&.left%=spritePtr&.sBoundsRect.right%
  50.   XELSE
  51.     LONG IF curRectPtr&.left%+spritePtr&.xDelta%>=spritePtr&.sBoundsRect+_right%
  52.       curRectPtr&.left%=spritePtr&.sBoundsRect.left%-(curRectPtr&.right%-curRectPtr&.left%)
  53.       curRectPtr&.right%=spritePtr&.sBoundsRect.left%
  54.     END IF
  55.   END IF
  56.   LONG IF curRectPtr&.bottom%+spritePtr&.yDelta%<=spritePtr&.sBoundsRect+_top%
  57.     curRectPtr&.bottom%=spritePtr&.sBoundsRect.bottom%+(curRectPtr&.bottom%-curRectPtr&.top%)
  58.     curRectPtr&.top%=spritePtr&.sBoundsRect.bottom%
  59.   XELSE
  60.     LONG IF curRectPtr&.top%+spritePtr&.yDelta%>=spritePtr&.sBoundsRect+_bottom%
  61.       curRectPtr&.top%=spritePtr&.sBoundsRect.top%-(curRectPtr&.bottom%-curRectPtr&.top%)
  62.       curRectPtr&.bottom%=spritePtr&.sBoundsRect+_top%
  63.     END IF
  64.   END IF
  65. EXITPROC
  66. RETURN
  67.  
  68. "SWTimeTask"
  69. 'Sets the frameTTHasFired or moveTTHasFired field of the sprite record
  70. 'to _zTrue (-1).  Called by the Time Manager if frameTimeInterval or
  71. 'moveTimeInterval field of sprite record > 0.
  72.  
  73. `                 move.w      #-1,tmXQSize(a1)  ;[move|frame]TTHasFired=_zTrue
  74. `                 rts                           ;return
  75.  
  76.  
  77.